package com.bigdata.appliance.controller;

import com.bigdata.appliance.common.pojo.PageResult;
import com.bigdata.appliance.service.ICartService;
import com.bigdata.appliance.vo.req.*;
import com.bigdata.appliance.vo.resp.GetUserAddressLIstRespVO;
import com.bigdata.appliance.vo.resp.PageCartRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 购物车表 前端控制器
 * </p>
 *
 * @author appliance-shop
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/api")
@Api(value = "CartController", tags = {"购物车接口"})
public class CartController {

    @Resource
    private ICartService iCartService;

    @PostMapping("/uniApp/cart/add")
    @ApiOperation(value = "添加地址接口")
    public void addCart(@RequestBody @Valid AddCartReqVO vo) {
        iCartService.addCarts(vo);
    }

    @PostMapping("/uniApp/cart/del")
    @ApiOperation(value = "修改地址接口")
    public void deleteCart(@RequestBody @Valid DeleteCartReqVO vo) {
        iCartService.deleteCarts(vo);
    }

    @PostMapping("/uniApp/cart")
    @ApiOperation(value = "获取用户地址接口")
    public PageResult<PageCartRespVO> getUserAddress(@RequestBody @Valid PageCartReqVO vo) {
        return iCartService.pageCart(vo);
    }
}
